<template>
  <div class="">
    <van-checkbox-group v-model="result" ref="ad">
      <van-swipe-cell
        v-for="(item, index) in $store.state.shoplist"
        :key="index"
      >
        <van-card
          :num="item.num"
          :price="item.product_price * item.num"
          :title="item.product_name"
          :thumb="item.product_picture"
          :desc="item.product_intro"
        >
          <template #footer>
            <button @click="sc(item)">删除</button>
            <van-stepper v-model="item.num" @change="change" />
          </template>
        </van-card>
      </van-swipe-cell>
    </van-checkbox-group>
  </div>
</template>

<script>
export default {
  data() {
    return {
      result: [],
    };
  },
  mounted() {},
  methods: {
    // 删除
    sc(val) {
      this.$store.commit("sc", val);
    },
    // 步进器
    change() {
      this.$store.commit("change");
    },
  },
  beforeRouteEnter(to, from, next) {
    next((vm) => {
      if (vm.$store.state.name) {
        next();
      } else {
        alert("您还没有登录");
        next("/");
      }
    });
  },
};
</script>

<style lang="scss"></style>
